/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package PackageMaker.Config;

import java.io.File;

/**
 *
 * @author wcss
 */
public class DependsModel {

    public static DependsModel load(String path) throws Exception {
        if (new File(path).exists()) {
            return (DependsModel) ObjectToXMLUtil.loadObjectFromXml(path);
        } else {
            return null;
        }
    }

    public static void save(DependsModel entry, String path) throws Exception {
        ObjectToXMLUtil.saveObjectToXml(entry, path);
    }
    
    public static final int moreThanVersion = 1;
    public static final int lessThanVersion = 2;
    public static final int allVersion = 3;

    public DependsModel() {
    }

    public DependsModel(String name, String version, int lessthan) {
        this.packageName = name;
        this.packageVersion = version;
        this.packageVersionType = lessthan;
    }
    /**
     * 包名
     */
    public String packageName = "";
    /**
     * 版本号
     */
    public String packageVersion = "";
    /**
     * 版本类型
     */
    public int packageVersionType = 0;

    public String toString() {
        if (packageVersionType == allVersion) {
            return this.packageName + "(All)";
        } else {
            if (packageVersionType == lessThanVersion) {
                return this.packageName + "(<=" + packageVersion + ")";
            } else {
                return this.packageName + "(>=" + packageVersion + ")";
            }
        }
    }
}
